package io.renren.modules.mybog.fromControoler;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;

import io.renren.modules.mybog.entity.PostEntity;
import io.renren.modules.mybog.fromControoler.utiles.R;
import io.renren.modules.mybog.service.PostService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author 小🌤
 * @since 2021-03-16
 */
@RestController
@RequestMapping("/bolg/post")
public class PostControllers {
    @Autowired
    private PostService postService;

    /**
     * 帖子的全部查询
     * @return
     */
    @GetMapping("/list")
    public R list(Integer page, Integer size, Integer id , String name){
        Page<PostEntity> postPage=new Page<>(page,size);
        Map<String,Object> map = postService.findAll(postPage,id,name);
        return R.ok().data("data",map);
    }
    @GetMapping("/info/{id}")
    public R info(@PathVariable("id")Integer id){
      PostEntity post= postService.listMessage(id);
    return R.ok().data("data",post);
    }
}

